package com.example.demo.entity;

import com.example.demo.myValidator.FlagValidator;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Min;
import java.io.Serializable;

/**
 * @author ml
 * @create 2017-07-10--13:44
 */
public class DemoEntity implements Serializable {

    @NotBlank//不能为空 检查时会将空格忽略
    @Length(min = 2,max = 10)//字符串长度在2到10中间
    private String name;

    @Min(value = 1)//字段值大于等于1
    private int age;

//非空校验、邮箱格式。
    @NotBlank
    @Email
    private String mail;

    @FlagValidator(values = "1,2,3")
    private String flag;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }
}
